# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gsasl
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.8.1
pkgrel=1
pkgdesc="Simple Authentication and Security Layer framework and a few common SASL mechanisms (mingw-w64)"
arch=('any')
url="https://josefsson.org/gsasl/"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('strip' 'staticlibs')
depends=("${MINGW_PACKAGE_PREFIX}-gss"
         "${MINGW_PACKAGE_PREFIX}-gnutls"
         "${MINGW_PACKAGE_PREFIX}-libidn"
         "${MINGW_PACKAGE_PREFIX}-libgcrypt"
         "${MINGW_PACKAGE_PREFIX}-libntlm"
         "${MINGW_PACKAGE_PREFIX}-readline")
source=("https://download.savannah.gnu.org/releases/gsasl/${_realname}-${pkgver}.tar.gz"
        "gsasl-avoid-conflicting-types.patch")
sha256sums=('4dda162a511976bfef14ad1fecd7733719dfd9c361b5d09dc8414ea9d472d8d2'
            '6d321e0d0ad49a1b6022f2b139f88fd17eb48af314e96dc50ccb228f255c8732')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/gsasl-avoid-conflicting-types.patch
}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static \
    --disable-kerberos_v5

  make -j1
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
